home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2005 March / Gamestar_71_2005-03_dvd.iso / Dema / willofsteel_demo.exe / {app} / Data / Shaders / Terrain14sf.fx < prev    next >
Text File  |  2004-10-23  |  5KB  |  191 lines

  1. float4x4 WorldViewProjection;
  2. float4x4 ShadowViewProjection;
  3. float4x4 TextureMatrix;
  4.  
  5. texture AlphaTexture;
  6. texture DiffuseTexture;
  7. texture ShadowTexture;
  8. texture CloudsTexture;
  9. texture FogOfWar;
  10.  
  11. float3 LightDirection = { 0.0f, 0.0f, 0.0f };
  12. float3 SunColor       = { 1., 0.86, .70 };
  13. float3 Ambient        = { 0.24, 0.12, 0.04 };
  14. float4 FogScale          = { 0.001953125, 0.001953125, 0.001953125, 0.001953125 };    
  15. float4 ZBias          = { 0.0, 0.0, 0.0, 0.003 };
  16. float4 ShadowOffset;
  17. float4 CloudUVShift    = { 0.0, 0.0, 0.0, 0.0 };
  18. float4 CloudScale      = { 0.01, 0.01, 0.01, 0.01 };
  19.  
  20.  
  21. technique Technique0
  22. {
  23.     pass Pass0
  24.     {
  25.         Texture[0]               = (DiffuseTexture);
  26.         Texture[1]               = (ShadowTexture);
  27.         Texture[2]               = (FogOfWar);
  28.  
  29.         VertexShaderConstant[0]   = <WorldViewProjection>;
  30.         VertexShaderConstant[4]   = <ShadowViewProjection>;
  31.         VertexShaderConstant[8]   = <TextureMatrix>;
  32.         VertexShaderConstant[27]  = <FogScale>;
  33.         VertexShaderConstant[30]  = <LightDirection>;
  34.         VertexShaderConstant[31]  = <ZBias>;
  35.         VertexShaderConstant[32]  = <SunColor>;
  36.  
  37.         VertexShader =
  38.         decl
  39.         {
  40.             stream 0;
  41.             float v0[3];      
  42.             float v3[3];      
  43.             float v6[2];      
  44.         }
  45.         asm
  46.         {
  47.             vs_1_1
  48.  
  49.             dcl_position v0
  50.             dcl_normal v3
  51.             dcl_texcoord0  v6
  52.  
  53.             def  c25,   1.0, 1.0, 1.0, 1.0
  54.             def  c26,   51.2, 0.01953125, 0.0, 0.0
  55.             m4x4  oPos, v0, c0    
  56.             mul   r0, v0, c27
  57.             mov   oT2.x, r0.x   
  58.             mov   oT2.y, r0.z   
  59.             dp3   r0, v3, c30
  60.             mul   oD0, r0, c32
  61.             mov   oT0, v6          
  62.             dp4   oT1.x, v0, c8    
  63.             dp4   oT1.y, v0, c9
  64.             dp4   r0, v0, c6       
  65.             add   oT3.x, r0, c31.w 
  66.        };
  67.  
  68.         PixelShaderConstant[17] = <Ambient>;
  69.  
  70.         PixelShader =
  71.         asm
  72.         {
  73.             ps_1_4
  74.               def c0, 1, 1, 1, 1
  75.             def c1, 0.0, 0.0, 0.0, 0
  76.             def c2, 1., 1., 1., 0
  77.  
  78.             def c16, 0.5, 0.065, 25.0, 1.0
  79.             def c18, 5., 0.2, 2., 1.0
  80.  
  81.             dcl t0.xy
  82.             dcl t1.xy
  83.             dcl t2.xy
  84.             dcl t3.x
  85.             dcl v0.rgba
  86.  
  87.             dcl_2d s0
  88.             dcl_2d s1
  89.             dcl_2d s2
  90.  
  91.             texld      r10, t1, s1          
  92.             sub        r9.r, r10.r, t3.x  
  93.             mov        r1, c1             
  94.             cmp        r10, r9.r, c0, r1  
  95.             texld      r1, t0, s0
  96.             mad        r0, r10, v0, c17   
  97.             texld      r2, t2, s2
  98.             mul        r0, r0, r2
  99.             mul        r0, r0, r1        
  100.             mov        oC0, r0            
  101.         };
  102.     }
  103. }
  104.  
  105. technique Technique1
  106. {
  107.     pass Pass0
  108.     {
  109.         Texture[0]               = (DiffuseTexture);
  110.         Texture[1]               = (ShadowTexture);
  111.         Texture[2]               = (FogOfWar);
  112.         Texture[3]               = (AlphaTexture);
  113.  
  114.         VertexShaderConstant[0]   = <WorldViewProjection>;
  115.         VertexShaderConstant[4]   = <ShadowViewProjection>;
  116.         VertexShaderConstant[8]   = <TextureMatrix>;
  117.         VertexShaderConstant[27]  = <FogScale>;
  118.         VertexShaderConstant[30]  = <LightDirection>;
  119.         VertexShaderConstant[31]  = <ZBias>;
  120.         VertexShaderConstant[32]  = <SunColor>;
  121.  
  122.         VertexShader =
  123.         decl
  124.         {
  125.             stream 0;
  126.             float v0[3]; 
  127.             float v3[3]; 
  128.             float v6[2]; 
  129.             float v8[2]; 
  130.         }
  131.         asm
  132.         {
  133.             vs_1_1
  134.             dcl_position v0
  135.             dcl_normal v3
  136.             dcl_texcoord0  v6
  137.             dcl_texcoord1  v8
  138.             mov      oT3.y, v0.y
  139.             m4x4  oPos, v0, c0        
  140.             mul   r0, v0, c27
  141.             mov   oT3.x, r0.x       
  142.             mov   oT3.y, r0.z       
  143.             m4x4  r0, v0, c12        
  144.             mov   oT0, v6           
  145.             mov   oT2, v8
  146.             dp4   oT1.x, v0, c8     
  147.             dp4   oT1.y, v0, c9
  148.             dp3   r0, v3, c30   
  149.             mul   oD0, r0, c32
  150.             dp4   r0, v0, c6        
  151.             add   oT4.x, r0, c31.w  
  152.         };
  153.  
  154.         PixelShaderConstant[17] = <Ambient>;
  155.  
  156.         PixelShader =
  157.         asm
  158.         {
  159.             ps_1_4
  160.               def c0, 1, 1, 1, 1
  161.             def c1, 0.0, 0.0, 0.0, 0
  162.             def c2, 1., 1., 1., 0
  163.             def c16, 0.5, 0.065, 25.0, 1.0
  164.             dcl t0.xy
  165.             dcl t1.xy
  166.             dcl t2.xy
  167.             dcl t3.xy
  168.             dcl t4.x
  169.             dcl v0.rgba
  170.  
  171.             dcl_2d s0
  172.             dcl_2d s1
  173.             dcl_2d s2
  174.             dcl_2d s3
  175.  
  176.             texld      r10, t1, s1       
  177.             sub     r9.r, r10.r, t4.x  
  178.             mov     r1, c1             
  179.             cmp     r10, r9.r, c0, r1  
  180.             texld      r1, t0, s0
  181.             mad     r0, r10, v0, c17   
  182.             texld      r2, t3, s2
  183.             mul        r0, r0, r2
  184.             mul     r0, r0, r1        
  185.             texld      r1, t2, s3
  186.             mov     r0.a, r1.a
  187.             mov       oC0, r0            
  188.         };
  189.     }
  190. }
  191.